package com.hgx.web.service.spring.service;

import com.google.gson.Gson;
import com.hgx.web.service.spring.entity.Customer;

import javax.ws.rs.*;

@Path("/crm")
public class CustomerService {

    @GET
    @Path("/customer/{customer_id}")
    @Produces("application/json")
    public Customer getCustomerById(@PathParam("customer_id") String customer_id) {
        Customer customer = new Customer(customer_id, "z3", 18);
        return customer;
    }


    @POST
    @Path("/addcustomer")
    @Consumes("application/json")
    @Produces("application/json")
    public String addCustomer(String customer_json) {
        Gson gson = new Gson();
        Customer customer = (Customer) gson.fromJson(customer_json, Customer.class);
        System.out.println(customer);
        return "success:  " + customer.toString();
    }

}
